package com.princess.demok.ui.demo

import android.animation.Keyframe
import android.animation.ObjectAnimator
import android.animation.PropertyValuesHolder
import android.app.Activity
import android.content.Intent
import android.view.View
import android.view.animation.AccelerateDecelerateInterpolator
import com.princess.baselib.utils.setOnClickListenerWithTrigger
import com.princess.demok.R
import com.princess.demok.base.view.MyBaseActivity
import kotlinx.android.synthetic.main.activity_bessel.*


/**
 * @author: xha
 * @date: 2021/10/22 10:27
 * @Description:
 */
class BesselActivity : MyBaseActivity() {

    companion object {
        @JvmStatic
        fun start(
            context: Activity
        ) {
            val starter = Intent(context, BesselActivity::class.java)
            context.startActivity(starter)
        }
    }

    override fun getLayoutId(): Int = R.layout.activity_bessel

    override fun initOnCreate() {

    }

    override fun initOnClickerListener() {
        super.initOnClickerListener()
        btnBessel.setOnClickListenerWithTrigger {
            startAnimation(keyFrameBessel)
            startAnimation(keySineBessel)
        }
    }

    fun startAnimation(view: View) {
        val keyframe1 = Keyframe.ofFloat(0f, 0f) // 开始：progress 为 0
        val keyframe2 = Keyframe.ofFloat(1f, 100f)
        val holder = PropertyValuesHolder.ofKeyframe("progress", keyframe1, keyframe2)
        val animator: ObjectAnimator = ObjectAnimator.ofPropertyValuesHolder(view, holder)
        animator.duration = 2500
        animator.interpolator = AccelerateDecelerateInterpolator()
        animator.start()
    }


}